using ClientWebSocketDemo.WebApi.BackgroundServices;
using ClientWebSocketDemo.WebApi.Models;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<IConfigClient, ConfigClient>();
builder.Services.AddHostedService<RegisterHostedService>();
var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
var client = app.Services.GetService<IConfigClient>();
client.ConnectAsync();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();